//
//  TKFriendListSetViewController.m
//  TKIMSDK
//
//  Created by TryHone on 16/6/29.
//  Copyright © 2016年 TryHone. All rights reserved.
//

#import "TKFriendListSetViewController.h"
#import "TKFriendListSetView.h"

@interface TKFriendListSetViewController ()



@end

@implementation TKFriendListSetViewController{
 
    TKFriendListSetView * friendlistsetview;

}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title=@"消息提醒设置";
    self.view.backgroundColor = [TKIMColorHelper stringToColor:@"#EFEFF4"];
    
    [TKIMSDKManager followAccount:APP_SDK_KEY callBack:^(NSInteger errorNumber, NSString *info, TKIMResultVo *data) {
        NSLog(@"%ld-%@",errorNumber,info);
        NSMutableArray* datasource=[[NSMutableArray alloc] init];
        if (errorNumber==0) {
            NSArray* tempdatasource=(NSArray*)data.results;
            if (tempdatasource&&tempdatasource.count) {
                for (NSDictionary* dict in tempdatasource) {
                    
                    TKIMUser * temp1=[[TKIMUser alloc] init];
                    temp1.userID = dict[@"subBztype"];
                    temp1.userName=dict[@"cnick_name"];
                    temp1.remark=dict[@"cnick_name"];
                    temp1.thumbPhotoUrl=dict[@"headImageUrl"];
                    temp1.isAcceptPush= [@"0" isEqualToString:dict[@"state"]]?YES:NO;
                    NSMutableDictionary* tempdict=[[NSMutableDictionary alloc] init];
                    
                    [tempdict setObject:dict[@"id"] forKey:@"msgtypeid"];
                    temp1.userExt=tempdict;
                    [datasource addObject:temp1];
                }
              
                
            }
            
        }
           friendlistsetview.userData=datasource;
    }];
}

-(void)loadView
{
    [super loadView];
    friendlistsetview=[[TKFriendListSetView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height-64)];
    [self.view addSubview:friendlistsetview];
    [self setBackBtn];
}

-(void)setBackBtn
{
    UIButton* back=[[UIButton alloc] initWithFrame:CGRectMake(0, 0, 90, 44)];
    [back addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    [back setImage:TKIMGetImage(@"btn_back") forState:UIControlStateNormal];
    back.tintColor=[UIColor whiteColor];
    back.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    UIBarButtonItem* leftBar=[[UIBarButtonItem alloc] initWithCustomView:back];
    self.navigationItem.leftBarButtonItem=leftBar;
}

//返回按钮被点击
-(void)back{
    [self.navigationController popViewControllerAnimated:YES];
}

@end
